<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>主页面</title>
  <!-- 引入 Bootstrap CSS -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
  <style>
    body {
      margin: 0;
      padding: 0;
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      display: flex;
      flex-direction: column;
      min-height: 100vh;
    }

    .header {
      background-color: #343a40;
      color: white;
      padding: 15px 20px;
      display: flex;
      align-items: center;
    }

    .header h1 {
      margin: 0;
      font-size: 24px;
      margin-left: 20px;
    }

    .sidebar {
      width: 250px;
      background-color: #343a40;
      color: white;
      padding-top: 20px;
      transition: width 0.3s ease;
    }

    .sidebar.collapsed {
      width: 60px;
    }

    .sidebar ul {
      list-style-type: none;
      padding: 0;
    }

    .sidebar li {
      padding: 15px 20px;
      cursor: pointer;
      transition: background-color 0.3s ease;
    }

    .sidebar li:hover {
      background-color: #495057;
    }

    .main-content {
      flex: 1;
      padding: 20px;
      background-color: #f8f9fa;
    }

    .toggle-btn {
      background-color: #343a40;
      color: white;
      border: none;
      padding: 5px 10px;
      border-radius: 5px;
      cursor: pointer;
      margin-right: 10px;
    }

    .page-container {
      display: flex;
      flex: 1;
    }
  </style>
  <script>
    function toggleSidebar() {
      const sidebar = document.querySelector('.sidebar');
      sidebar.classList.toggle('collapsed');
    }

    function loadPage(pageUrl) {
      const mainContent = document.querySelector('.main-content');
      const xhr = new XMLHttpRequest();
      xhr.open('GET', pageUrl, true);
      xhr.onreadystatechange = function () {
        if (xhr.readyState === 4 && xhr.status === 200) {
          mainContent.innerHTML = xhr.responseText;
        }
      };
      xhr.send();
    }
  </script>
</head>
<body>
<div class="header">
  <button class="toggle-btn" onclick="toggleSidebar()">≡</button>
  <h1>墙体材料选择决策系统</h1>
</div>
<div class="page-container">
  <div class="sidebar" id="sidebar">
    <ul>
      <li onclick="loadPage('home.jsp')">首页</li>
      <li onclick="loadPage('recommendation.jsp')">墙体材料推荐</li>
      <li onclick="loadPage('communication.jsp')">用户交流</li>
      <li onclick="loadPage('profile.jsp')">个人中心</li>
    </ul>
  </div>
  <div class="main-content">
    <!-- 初始加载首页 -->
    <script>
      loadPage('home.jsp');
    </script>
  </div>
</div>
<!-- 引入 Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>